//
//  HotViewController.m
//  Computer
//
//  Created by qianfeng on 15/10/20.
//  Copyright © 2015年 qianfeng. All rights reserved.
//

#import "HotViewController.h"
#import "Header.h"
#import "HotCell.h"
#import "HotListViewController.h"
@interface HotViewController ()

@end
static NSString *cellID = @"HotCell";
@implementation HotViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self createBarButtonLeftTitle:nil leftImage:nil rightTitle:@"攒机" rightImage:@"button_more"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark -实现UITableView相关方法-

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return [CATEGORY_ARRRAY_TITLE count];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [[CATEGORY_ARRAY objectAtIndex:section] count];
}
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    return [CATEGORY_ARRRAY_TITLE objectAtIndex:section];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    HotCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (!cell) {
        cell = [[[NSBundle mainBundle]loadNibNamed:cellID owner:nil options:nil] lastObject];
    }
    cell.contentLabel.text = [[CATEGORY_ARRAY objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"点击了%@",[[CATEGORY_ARRAY objectAtIndex:indexPath.section] objectAtIndex:indexPath.row]);

    HotListViewController *hlvc = [[HotListViewController alloc]initWithTitle:[[CATEGORY_ARRAY objectAtIndex:indexPath.section] objectAtIndex:indexPath.row ]];
    hlvc.number = [NSString stringWithFormat:@"%lu",indexPath.row + 1];
    [self.navigationController pushViewController:hlvc animated:YES];
}
@end
